﻿using System.IO;

namespace DirectoryCopier
{
    class DirectoryCopier
    {
        static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination)
        {
            if(!Directory.Exists(destination.FullName))
            {
                Directory.CreateDirectory(destination.FullName);
            }
            FileInfo[] files = source.GetFiles();
            foreach(FileInfo file in files)
            {
                file.CopyTo(Path.Combine(destination.FullName,file.Name));
            }
            DirectoryInfo[] subdirectories = source.GetDirectories();
            foreach (DirectoryInfo subdirectory in subdirectories)
	        {
                DirectoryInfo subDestination = new DirectoryInfo(Path.Combine(destination.FullName, subdirectory.Name));
                CopyDirectory(subdirectory, subDestination);
	        }
        }

        static void Main(string[] args)
        {
            string sourceName = @"..\..\Hello\";
            string newLocation = @"..\..\Copy\";
            DirectoryInfo source = new DirectoryInfo(sourceName);
            DirectoryInfo target = new DirectoryInfo(newLocation + source.Name);
            CopyDirectory(source, target);
        }
    }
}
